<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta HTTP-EQUIV="Expires" CONTENT="-1">
<link rel="shortcut icon" href="images/favicon.png">
<link rel="icon" href="images/favicon.png">
<title>ASUS Wireless Router <#Web_Title#> - <#menu5_2_3#></title>
<link rel="stylesheet" type="text/css" href="/bootstrap/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="/bootstrap/css/main.css">
<link rel="stylesheet" type="text/css" href="/bootstrap/css/engage.itoggle.css">

<script type="text/javascript" src="/jquery.js"></script>
<script type="text/javascript" src="/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/bootstrap/js/engage.itoggle.min.js"></script>
<script language="JavaScript" type="text/javascript" src="/state.js"></script>
<script language="JavaScript" type="text/javascript" src="/general.js"></script>
<script language="JavaScript" type="text/javascript" src="/popup.js"></script>
<script type="text/javascript" language="JavaScript" src="/help.js"></script>
<script type="text/javascript" language="JavaScript" src="/detect.js"></script>

<script>
    var $j = jQuery.noConflict();
    $j(document).ready(function() {
        $j('#dr_enable_x_on_of').iToggle({
            easing: 'linear',
            speed: 70,
            onClickOn: function(){
                change_common_radio(this, 'WLANConfig11b', 'dr_enable_x', '1');
                $j("#dr_enable_x_fake").attr("checked", "checked").attr("value", 1);
                $j("#dr_enable_x_1").attr("checked", "checked");
                $j("#dr_enable_x_0").removeAttr("checked");
            },
            onClickOff: function(){
                change_common_radio(this, 'WLANConfig11b', 'dr_enable_x', '0');
                $j("#dr_enable_x_fake").removeAttr("checked").attr("value", 0);
                $j("#dr_enable_x_0").attr("checked", "checked");
                $j("#dr_enable_x_1").removeAttr("checked");
            }
        });
        $j("#dr_enable_x_on_of label.itoggle").css("background-position", $j("input#dr_enable_x_fake:checked").length > 0 ? '0% -27px' : '100% -27px');

        $j('#sr_enable_x_on_of').iToggle({
            easing: 'linear',
            speed: 70,
            onClickOn: function(){
                change_common_radio(this, 'WLANConfig11b', 'sr_enable_x', '1');
                $j("#sr_enable_x_fake").attr("checked", "checked").attr("value", 1);
                $j("#sr_enable_x_1").attr("checked", "checked");
                $j("#sr_enable_x_0").removeAttr("checked");
            },
            onClickOff: function(){
                change_common_radio(this, 'WLANConfig11b', 'sr_enable_x', '0');
                $j("#sr_enable_x_fake").removeAttr("checked").attr("value", 0);
                $j("#sr_enable_x_0").attr("checked", "checked");
                $j("#sr_enable_x_1").removeAttr("checked");
            }
        });
        $j("#sr_enable_x_on_of label.itoggle").css("background-position", $j("input#sr_enable_x_fake:checked").length > 0 ? '0% -27px' : '100% -27px');
    })
</script>

<script>
wan_route_x = '<% nvram_get_x("IPConnection", "wan_route_x"); %>';
wan_nat_x = '<% nvram_get_x("IPConnection", "wan_nat_x"); %>';
wan_proto = '<% nvram_get_x("Layer3Forwarding",  "wan_proto"); %>';

<% login_state_hook(); %>
var wireless = [<% wl_auth_list(); %>];	// [[MAC, associated, authorized], ...]
var GWStaticList = [<% get_nvram_list("RouterConfig", "GWStatic"); %>];

function initial(){
	show_banner(1);
	show_menu(5,2,3);
	show_footer();
	
	enable_auto_hint(6, 5);
	showGWStaticList();
}

function applyRule(){
	showLoading();
	
	document.form.action_mode.value = " Restart ";
	document.form.current_page.value = "/Advanced_GWStaticRoute_Content.asp";
	document.form.next_page.value = "";
	document.form.submit();
}

function done_validating(action){
	refreshpage();
}

function GWStatic_markGroup(o, s, c, b) {	
	document.form.group_id.value = s;	
	
	if(b == " Add "){
		if (document.form.sr_num_x_0.value > c){
			alert("<#JS_itemlimit1#> " + c + " <#JS_itemlimit2#>");
			return false;
		}
		else if (!validate_ipaddr(document.form.sr_ipaddr_x_0, "") ||
				 !validate_ipaddr(document.form.sr_netmask_x_0, "") ||
				 !validate_ipaddr(document.form.sr_gateway_x_0, "")){
				 return false;
		}
		else if (document.form.sr_ipaddr_x_0.value == ""){
				 alert("<#JS_fieldblank#>");
				 document.form.sr_ipaddr_x_0.focus();
				 return false;				 
		}
		else if (document.form.sr_netmask_x_0.value == ""){
				 alert("<#JS_fieldblank#>");
				 document.form.sr_netmask_x_0.focus();
				 return false;				 
		}
		else if (document.form.sr_gateway_x_0.value == ""){
				 alert("<#JS_fieldblank#>");
				 document.form.sr_gateway_x_0.focus();
				 return false;				 
		}				
		else if (GWStatic_validate_duplicate_noalert(GWStaticList, document.form.sr_ipaddr_x_0.value, 16, 0) &&
				 GWStatic_validate_duplicate_noalert(GWStaticList, document.form.sr_netmask_x_0.value, 16, 1) &&
				 GWStatic_validate_duplicate_noalert(GWStaticList, document.form.sr_gateway_x_0.value, 16, 2) &&
				 GWStatic_validate_duplicate(GWStaticList, document.form.sr_if_x_0.value, 2, 4)
				) return false;  //Check the IP, Submask, gateway and Interface is duplicate or not.
	}
	
	pageChanged = 0;
	pageChangedCount = 0;
	
	document.form.action_mode.value = b;
	return true;		
}

function GWStatic_validate_duplicate_noalert(o, v, l, off){
	for (var i=0; i < o.length; i++)
	{
		if (entry_cmp(o[i][off], v, l)==0){ 
			return true;
		}
	}
	return false;
}

function GWStatic_validate_duplicate(o, v, l, off){
	for(var i = 0; i < o.length; i++){
		if(entry_cmp(o[i][off].toLowerCase(), v.toLowerCase(), l) == 0){
			alert('<#JS_duplicate#>');
			return true;
		}
	}
	return false;
}

function showGWStaticList(){
	var code = "";
	code +='<table width="100%" cellspacing="0" cellpadding="3" align="center" class="table table-striped table-bordered table-condensed">';
	if(GWStaticList.length == 0)
		code +='<tr><td><#IPConnection_VSList_Norule#></td></tr>';
	else{
		for(var i = 0; i < GWStaticList.length; i++){
		code +='<tr id="row' + i + '">';
		code +='<td width="110">' + GWStaticList[i][0] + '</td>';	//IP
		code +='<td width="110">' + GWStaticList[i][1] + '</td>';	//Mask
		code +='<td width="110">' + GWStaticList[i][2] + '</td>';	//Gateway
		code +='<td width="48">' + GWStaticList[i][3] + '</td>';	//Metric
		code +='<td width="65">' + GWStaticList[i][4] + '</td>';	//Interface
		code +='<td width="20"><input type="checkbox" name="GWStatic_s" value="' + i + '" onClick="changeBgColor(this,' + i + ');" id="check' + i + '"></td>';
		if(i == 0)
			code +='<td style="background:#C0DAE4;" rowspan="' + GWStaticList.length + '"><input class="btn" type="submit" onclick="markGroup(this, \'GWStatic\', 32, \' Del \');" value="<#CTL_del#>"/></td>';
		
		code +='</tr>';
		}
	}
	code +='</table>';
	
	$("GWStaticList_Block").innerHTML = code;
}

function changeBgColor(obj, num){
	if(obj.checked)
 		$("row" + num).style.background='#FF9';
	else
 		$("row" + num).style.background='#FFF';
}

</script>

<style>
    .table th, .table td{vertical-align: middle;}
    .table input, .table select {margin-bottom: 0px;}
</style>
</head>

<body onload="initial();" onunLoad="disable_auto_hint(6, 5);return unload_body();">
<div class="container-fluid" style="padding-right: 0px">
    <div class="row-fluid">
        <div class="span2"><center><div id="logo"></div></center></div>
        <div class="span10" >
            <div id="TopBanner"></div>
        </div>
    </div>
</div>

<div id="Loading" class="popup_bg"></div>

<iframe name="hidden_frame" id="hidden_frame" src="" width="0" height="0" frameborder="0"></iframe>
<form method="post" name="form" id="ruleForm" action="/start_apply.htm" target="hidden_frame">
<input type="hidden" name="current_page" value="Advanced_GWStaticRoute_Content.asp">
<input type="hidden" name="next_page" value="">
<input type="hidden" name="next_host" value="">
<input type="hidden" name="sid_list" value="RouterConfig;">
<input type="hidden" name="group_id" value="GWStatic">
<input type="hidden" name="modified" value="0">
<input type="hidden" name="action_mode" value="">
<input type="hidden" name="first_time" value="">
<input type="hidden" name="action_script" value="">
<input type="hidden" name="preferred_lang" id="preferred_lang" value="<% nvram_get_x("LANGUAGE", "preferred_lang"); %>">
<input type="hidden" name="wl_ssid2" value="<% nvram_get_x("WLANConfig11b",  "wl_ssid2"); %>">
<input type="hidden" name="firmver" value="<% nvram_get_x("",  "firmver"); %>">
<input type="hidden" name="sr_num_x_0" value="<% nvram_get_x("RouterConfig", "sr_num_x"); %>" readonly="1">

<div class="container-fluid">
    <div class="row-fluid">
        <div class="span2">
            <!--Sidebar content-->
            <!--=====Beginning of Main Menu=====-->
            <div class="well sidebar-nav side_nav" style="padding: 0px;">
                <ul id="mainMenu" class="clearfix"></ul>
                <ul class="clearfix">
                    <li>
                        <div id="subMenu" class="accordion"></div>
                    </li>
                </ul>
            </div>
        </div>

        <div class="span10">
            <!--Body content-->
            <div class="row-fluid">
                <div class="span12">
                    <div class="box well grad_colour_dark_blue">
                        <h2 class="box_head round_top"><#menu5_2#> - <#menu5_2_3#></h2>
                        <div class="round_bottom">
                            <div class="row-fluid">
                                <div id="tabMenu" class="submenuBlock"></div>
                                <div class="alert alert-info" style="margin: 10px;"><#RouterConfig_GWStaticEnable_sectiondesc#></div>

                                <table width="100%" align="center" cellpadding="4" cellspacing="0" class="table">
                                    <tr>
                                        <th colspan="2" style="background-color: #E3E3E3;">
                                            <#menu5_2_3#>
                                        </th>
                                    </tr>
                                    <tr>
                                        <th width="50%"><#RouterConfig_GWDHCPEnable_itemname#></th>
                                        <td>
                                            <div class="main_itoggle">
                                                <div id="dr_enable_x_on_of">
                                                    <input type="checkbox" id="dr_enable_x_fake" <% nvram_match_x("WLANConfig11b", "dr_enable_x", "1", "value=1 checked"); %><% nvram_match_x("WLANConfig11b", "dr_enable_x", "0", "value=0"); %>>
                                                </div>
                                            </div>

                                            <div style="position: absolute; margin-left: -10000px;">
                                                <input type="radio" value="1" name="dr_enable_x" id="dr_enable_x_1" class="input" onClick="return change_common_radio(this, 'RouterConfig', 'dr_enable_x', '1')" <% nvram_match_x("RouterConfig", "dr_enable_x", "1", "checked"); %>><#checkbox_Yes#>
                                                <input type="radio" value="0" name="dr_enable_x" id="dr_enable_x_0" class="input" onClick="return change_common_radio(this, 'RouterConfig', 'dr_enable_x', '0')" <% nvram_match_x("RouterConfig", "dr_enable_x", "0", "checked"); %>><#checkbox_No#>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th><#RouterConfig_GWStaticEnable_itemname#></th>
                                        <td>
                                            <div class="main_itoggle">
                                                <div id="sr_enable_x_on_of">
                                                    <input type="checkbox" id="sr_enable_x_fake" <% nvram_match_x("WLANConfig11b", "sr_enable_x", "1", "value=1 checked"); %><% nvram_match_x("WLANConfig11b", "sr_enable_x", "0", "value=0"); %>>
                                                </div>
                                            </div>

                                            <div style="position: absolute; margin-left: -10000px;">
                                                <input type="radio" value="1" name="sr_enable_x" id="sr_enable_x_1" class="input" onclick="return change_common_radio(this, 'RouterConfig', 'sr_enable_x', '1')" <% nvram_match_x("RouterConfig", "sr_enable_x", "1", "checked"); %>><#checkbox_Yes#>
                                                <input type="radio" value="0" name="sr_enable_x" id="sr_enable_x_0" class="input" onclick="return change_common_radio(this, 'RouterConfig', 'sr_enable_x', '0')" <% nvram_match_x("RouterConfig", "sr_enable_x", "0", "checked"); %>><#checkbox_No#>
                                            </div>
                                        </td>
                                    </tr>
                                </table>

                                <table width="100%" align="center" cellpadding="4" cellspacing="0" class="table">
                                    <tr>
                                        <th colspan="6" style="background-color: #E3E3E3;"><#RouterConfig_GWStatic_groupitemdesc#></th>
                                    </tr>
                                    <tr>
                                        <th width="20%"><a class="help_tooltip" href="javascript:void(0);" onmouseover="openTooltip(this,6,1);"><#RouterConfig_GWStaticIP_itemname#></a></th>
                                        <th width="20%"><a class="help_tooltip" href="javascript:void(0);" onmouseover="openTooltip(this,6,2);"><#RouterConfig_GWStaticMask_itemname#></a></th>
                                        <th width="20%"><a class="help_tooltip" href="javascript:void(0);" onmouseover="openTooltip(this,6,3);"><#RouterConfig_GWStaticGW_itemname#></a></th>
                                        <th width="10%"><a class="help_tooltip" href="javascript:void(0);" onmouseover="openTooltip(this,6,4);"><#RouterConfig_GWStaticMT_itemname#></a></th>
                                        <th width="10%"><a class="help_tooltip" href="javascript:void(0);" onmouseover="openTooltip(this,6,5);"><#RouterConfig_GWStaticIF_itemname#></a></th>
                                        <th width="20%">&nbsp;</th>
                                    </tr>
                                    <tr>
                                        <td><input type="text" maxlength="15" class="span12" size="12" name="sr_ipaddr_x_0" onKeyPress="return is_ipaddr(this)" onKeyUp="change_ipaddr(this)"/></td>
                                        <td><input type="text" maxlength="15" class="span12" size="12" name="sr_netmask_x_0" onKeyPress="return is_ipaddr(this)" onKeyUp="change_ipaddr(this)"/></td>
                                        <td><input type="text" maxlength="15" class="span12" size="12" name="sr_gateway_x_0" onKeyPress="return is_ipaddr(this)" onKeyUp="change_ipaddr(this)"/></td>
                                        <td><input type="text" maxlength="3"  class="span12" size="1" name="sr_matric_x_0"  onkeypress="return is_number(this)"></td>
                                        <td>
                                            <select name="sr_if_x_0" class="span12">
                                                <option value="LAN" <% nvram_match_list_x("RouterConfig","sr_if_x", "LAN","selected", 0); %>>LAN</option>
                                                <option value="MAN" <% nvram_match_list_x("RouterConfig","sr_if_x", "MAN","selected", 0); %>>MAN</option>
                                                <option value="WAN" <% nvram_match_list_x("RouterConfig","sr_if_x", "WAN","selected", 0); %>>WAN</option>
                                            </select>
                                        </td>
                                        <td>
                                            <input class="btn btn-primary span12" style="max-width: 219px" type="submit" onClick="return GWStatic_markGroup(this, 'GWStatic', 32, ' Add ');" name="GWStatic" value="<#CTL_add#>">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="6" style="border-top: 0 none;">
                                            <div id="GWStaticList_Block"></div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="6" style="border-top: 0 none;">
                                            <center><input class="btn btn-primary" style="width: 219px" type="button" value="<#CTL_apply#>" onclick="applyRule()" /></center>
                                        </td>
                                    </tr>
                                </table>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

</form>

<!--==============Beginning of hint content=============-->
<div id="help_td" style="position: absolute; margin-left: -10000px" valign="top">
    <form name="hint_form"></form>
    <div id="helpicon" onClick="openHint(0,0);"><img src="images/help.gif" /></div>

    <div id="hintofPM" style="display:none;">
        <table width="100%" cellpadding="0" cellspacing="1" class="Help" bgcolor="#999999">
        <thead>
            <tr>
                <td>
                    <div id="helpname" class="AiHintTitle"></div>
                    <a href="javascript:;" onclick="closeHint()" ><img src="images/button-close.gif" class="closebutton" /></a>
                </td>
            </tr>
        </thead>

            <tr>
                <td valign="top" >
                    <div class="hint_body2" id="hint_body"></div>
                    <iframe id="statusframe" name="statusframe" class="statusframe" src="" frameborder="0"></iframe>
                </td>
            </tr>
        </table>
    </div>
</div>
<!--==============Ending of hint content=============-->

<div id="footer"></div>

</body>
</html>
